#include<bits/stdc++.h>
using namespace std;
const int N=100010,N1=2005;
int n,m,T;
double l,vl;
double d[N],v[N],a[N];
double p[N];
bool b[N];
bool vist[N];
int cnt=0,ans;
bool sc(int k){
    for(int i=1;i<=m;i++){
        if(b[i]==true&&p[i]>=d[k]&&(v[k]*v[k]+2*a[k]*(p[i]-d[k]))>=0&&sqrt(v[k]*v[k]+2*a[k]*(p[i]-d[k]))>vl){
            return true;
        }
    }
    return false;
}
int cs(){
    for(int i=1;i<=n;i++){
        if(sc(i)!=vist[i]) return false;
        //cout<<sc(i);
    }
    return true;
}
void dfs(int deep){
    if(deep>m){
        cnt=0;
        for(int i=1;i<=m;i++){
            if(b[i]==true) cnt++;
        }
        if(cs()==true) ans=min(ans,cnt);
        return ;
    }
    b[deep]=true;
    dfs(deep+1);
    b[deep]=false;
    dfs(deep+1);
    return;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        memset(b,true,sizeof(b));
        ans=0;
        scanf("%d",&n);
        scanf("%d",&m);
        scanf("%lf",&l);
        scanf("%lf",&vl);
        for(int i=1;i<=n;i++){
            scanf("%lf",&d[i]);
            scanf("%lf",&v[i]);
            scanf("%lf",&a[i]);
        }
        for(int i=1;i<=m;i++){
            scanf("%lf",&p[i]);
        }
        for(int i=1;i<=n;i++){
            vist[i]=sc(i);
            ans+=sc(i);
        }
        printf("%d ",ans);
        ans=m;
        dfs(1);
        printf("%d\n",m-ans);
    }
    return 0;
}
